#pragma once
#include "Precompile.h"

namespace Utility{
	class MatrixCamera : public ICamera{
	public:
		MatrixCamera();
		~MatrixCamera(){}

	    void createProjectionMatrix( float fov, float aspect, float nearPlane, float farPlane );
	    void moveForward( float units );
	    void strafe( float units ); 
		void moveUp( float units );    
		
		void yaw( float radians );
		void pitch( float radians );
		void roll( float radians );
	    void update(float dt);

	    void setPosition( Math::Vector<float>* pPosition );
	    void setLookAt( Math::Vector<float>* pLookAt );

	    void setFOV( float fov )            { createProjectionMatrix( fov, m_aspect, m_nearPlane, m_farPlane ); }
	    void setAspectRatio( float aspect ) { createProjectionMatrix( m_fov, aspect, m_nearPlane, m_farPlane ); }
	    void setNearPlane( float plane )    { createProjectionMatrix( m_fov, m_aspect, plane, m_farPlane ); }
	    void setFarPlane( float plane )     { createProjectionMatrix( m_fov, m_aspect, m_nearPlane, plane ); }

	    void setMaxVelocity( float maxVelocity ) { m_maxVelocity = maxVelocity; }
	    void setInvertY( bool invert )           { m_invertY = invert; }
	    void setMaxPitch( float maxPitch )       { m_maxPitch = maxPitch; }

	    Math::Vector<float>* getLookAt()   		       { return &m_lookAt; }
	    float getFOV()                     { return m_fov; }
	    float getAspectRatio()             { return m_aspect; }
	    float getNearPlane()               { return m_nearPlane; }
	    float getFarPlane()                { return m_farPlane; }
	    float getMaxVelocity()             { return m_maxVelocity; }
	    bool  getInvertY()                 { return m_invertY; }
	    float getPitch()                   { return m_pitch; }
	    float getYaw()                     { return m_yaw; }
	    float getMaxPitch()                { return m_maxPitch; }

		Math::Matrix<4,4>& getViewProjection();
		
		int	  getSpeed()					{return m_speed;}

		void updateViewMatrix();

	private:
		Math::Vector<float> m_right;     
	    Math::Vector<float> m_up;        
	    Math::Vector<float> m_look;
	    Math::Vector<float> m_lookAt;    
	    Math::Vector<float> m_velocity;  
	    float       m_yaw;       
	    float       m_pitch;     
	    float       m_maxPitch;
	    float       m_maxVelocity;
	    float       m_fov;       
	    float       m_aspect;    
	    float       m_nearPlane;
	    float       m_farPlane;
	    bool        m_invertY;
	    bool        m_enableYMovement;

		boost::timer	m_velocityTimer;
		float			m_distTraveled;
		int				m_speed;
	};
}